import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.gargoylesoftware.htmlunit.util.NameValuePair;
import com.qq.spirit.GameConstants;
import com.qq.spirit.HttpUtil;

import flex.messaging.util.URLEncoder;

public class MTest
{
	private String tStr = null;
	private String regex = null;

	@SuppressWarnings("unchecked")
	public List apartNumber(String str)
	{
		this.tStr = str;
		List apartNum = new ArrayList();
		StringTokenizer st = new StringTokenizer(tStr, " ,，");
		while (st.hasMoreTokens())
		{
			String apStr = st.nextToken();
			apartNum.add(apStr);
		}
		return apartNum;
	}

	@SuppressWarnings("unchecked")
	public List getNumber(List l)
	{
		regex = "(((010|02\\d{1}|0[3-9]\\d{2})\\d{7,8}|1([358]\\d{1}|58|59)\\d{8}))";
		List getNum = new ArrayList();
		Iterator e = l.iterator();
		while (e.hasNext())
		{
			tStr = (String) e.next();
			if (Pattern.matches(regex, tStr))
			{
				getNum.add(tStr);
			}
		}
		l.clear();
		return getNum;
	}

	public void showNumber(List l)
	{
		Iterator e = l.iterator();
		while (e.hasNext())
		{
			System.out.println(e.next());
		}
	}

	public boolean checkNumber(String str)
	{
		regex = "(((010|02\\d{1}|0[3-9]\\d{2})\\d{7,8}|1(3\\d{1}|58|59)\\d{8}))";
		this.tStr = str;
		return (Pattern.matches(regex, tStr));
	}

	/**
	 * The main method for test.
	 */
	public static void main(String[] args)
	{
		System.out.println(java.net.URLDecoder.decode("4%3A0%3B3"));
//		MTest rtest = new MTest();
//		List tarList, aprList = new ArrayList();
//		aprList = rtest.apartNumber("15012661723,1534567,051068109456,0248563950");
//		tarList = rtest.getNumber(aprList);
//		rtest.showNumber(tarList);
//		List<NameValuePair> nvpList = new ArrayList<NameValuePair>();
//		nvpList.add(new NameValuePair("scopeId", scopeId+""));
//		HttpUtil.doPost(username, GameConstants.BOWLDER_RES_INFO_URL, nvpList, new BowlderResInfo(username, scopeId));
	}
}
